package com.zzh.partnersys.common.enums;

import lombok.Data;
import lombok.Getter;

/**
 * 状态枚举类
 * @author zzh
 */
@Getter
public enum StatusEnum {

    /**
     * 禁用状态
     */
    DISABLED(0, "禁用状态"),
    /**
     * 启用状态
     */
    ENABLED(1, "启用状态");


    private final int code;
    private final String desc;

    StatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String getDescByCode(int code) {
        for (StatusEnum value : StatusEnum.values()) {
            if (value.code == code) {
                return value.desc;
            }
        }
        return null;
    }

    public static int getCodeByDesc(String desc) {
        for (StatusEnum value : StatusEnum.values()) {
            if (value.desc.equals(desc)) {
                return value.code;
            }
        }
        return -1;
    }


}
